<?php
	include("../includes/main_inc.php");
	
	if($_GET['id']) $id=$_GET['id'];
	elseif ($_POST['id']) $id=$_POST['id'];
	
	if($_POST['Delete']=="Delete"){
		if(is_array($_POST['DFiles'])){
			$m= new DeleteFromDatabase();
			$m->AddIDArray($_POST['DFiles']);
			$m->AddTable("affiliateBanners");
			$Errors=$m->DoDelete();
			
			if($Errors==""){
				$Message="Banners Deleted";
			}else{
				$Message=$Errors;
			};
		}else{
			$Message="No Administrators Selected To Delete";
		};
	};
	
	
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Affiliate Bubble Administration</title>

<link href="<?=$rootdir?>css/admin.css" rel="stylesheet" type="text/css">
<script src="<?=$rootdir?>jscript/menuArray.js" language="javascript"></script>
<script src="<?=$rootdir?>jscript/clock.js" language="javascript"></script>
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style2 {font-weight: bold}
-->
</style>
</head>

<body onLoad="funClock();">
<?php include("../includes/header.php"); ?>
<table width="100%" border="0" cellspacing="25" cellpadding="0">
<tr>
<td valign="top" width="240"><div id="menu">
  <?php include("../menu/advertsmenu.php"); ?>
</div></td>
<td align="center" valign="top">

<div id="titleCompact"> Program Banners / <a href="banner.php?affiliateProgramsID=<?=$id;?>">Add New Banner </a></div>

<div id="contentCompact">
<?=$Message;?>
  <form name="form1" method="post" action="view-banners.php">
    <table width="600" border="0" cellpadding="5" cellspacing="1" bgcolor="#E9EEF5">
      <tr id="formHeader">
        <td width="131"><strong>Name </strong></td>
        <td width="182" align="center"><strong>Target URL</strong></td>
        <td width="182" align="center"><strong>Banner</strong></td>
        <td width="70" align="center"><strong>Delete</strong></td>
      </tr>
      <?php
	$Count=0;
	$r=new ReturnRecord();
	$sq2=$r->rawQuery("SELECT id,Name,TargetURL,BType,HTMLCode,Image FROM affiliateBanners WHERE affiliateProgramsID=$id");  
	while ($myrow = mysql_fetch_row($sq2)) {
?>
      <tr bgcolor="<?=(($Count%2)==0 ? "#FFFFFF" : "#EBEBEB"); ?>">
        <td><?=$myrow[1];?></td>
        <td align="center">http://<?=$myrow[2];?></td>
        <td align="center"><?
		
		if($myrow[3]=="Image"){
		?><img src="<?=$rootdir?>banners/<?=$myrow[5]?>"><?
		}else{
			print $myrow[4];
		};
		
		?></td>
        <td align="center"><input type="checkbox" name="DFiles[]" value="<?=$myrow[0];?>"></td>
      </tr>
      <?
		$Count++;
	};
?>

      <tr>
        <td colspan="3" bgcolor="#FFFFFF"><input name="id" type="hidden" id="id" value="<?=$id;?>"></td>
        <td align="center" bgcolor="#FFFFFF"><input name="Delete" type="submit" id="Delete" value="Delete" class="formButtonSubmit"></td>
      </tr>
    </table>
      </form>
  </div>

</td>
</tr>
</table>
</body>
</html>
